package cc.yugu.yhdw.webserver.service.basic;

import cc.yugu.yhdw.common.constant.CacheKey;
import cc.yugu.yhdw.common.domain.basic.SystemConfig;
import cc.yugu.yhdw.common.tool.memcached.MemCachedConfig;
import com.whalin.MemCached.MemCachedClient;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * 系统配置业务切面类
 * 
 * @Date:Created in 2018/7/5 14:35
 * @Author:
 * @Modified By: zjn 2018/7/5 14:35
 */ 
@Aspect
@Service
public class SystemConfigServiceAspect {

    @Autowired
    MemCachedClient memCachedClient;

    @Pointcut("execution(* cc.yugu.yhdw.webserver.service.basic.SystemConfigService.update(..))")
    private void update() {}
    /**
    * 更新
    *
    * @Param: [joinPoint]
    * @Return: void
    * @Author By: zjn 2018/7/5  14:35
    */
    @Around("update()")
    public void update(ProceedingJoinPoint joinPoint) throws Throwable {
        SystemConfig systemConfig = (SystemConfig) joinPoint.getArgs()[0];
        String key = CacheKey.key(CacheKey.K_ID_V_SYSTEM_CONFIG_VALUE, systemConfig.getId());
        joinPoint.proceed();
        memCachedClient.delete(key);
    }
}
